package com.nt.train.config.properties;

import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author hlf
 * @version 1.0
 * @date 2022/7/31 9:03
 */
//注解开关
@ConditionalOnProperty( prefix = "jwt" ,name="enable",havingValue = "true")
@Component
@Data
public class JwtUtil {

    private static String  header ="";

    private static String  username ="";

    private static String  password ="";

    @Autowired
    private Environment environment;

    public JwtUtil(Environment environment){
      this.environment = environment ;
    }

    @PostConstruct
    public  void config(){
        header = environment.getProperty("jwt.header");
        username = environment.getProperty("jwt.username");
        password = environment.getProperty("jwt.password");
    }
}
